<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Mapping {

	function __construct() {
        $this->CI = & get_instance();
        
    }

//顯示你物件的比對資料
    function object( $resu , $object_fields ) {
        

    	$html ='<h5 style="font-size:17px;">物件</h5>';
        $html .='<table style="border-width:1px; border-style:solid;color:red;"><tr>';
		$ff=1;
		foreach($resu->result() as $demand){
		    foreach ($object_fields as $f_name) {

		        if( $f_name!='client_id'  AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
		            AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' AND $f_name!='status' 
		            AND $f_name!='ref_client_verify_code' AND $f_name!='demand_id' AND $f_name!='client_contact_id' 
		            AND $f_name!='point_count' AND $f_name!='shop_point_id'  AND $f_name!='owner' AND $f_name!='object_id'     )
		        if( !empty($demand->$f_name)     AND 
		             $demand->$f_name!='0.00'  ){

		            $html.='<th>'.$f_name.'</th>';
		            
		            if($ff%5==0 AND $ff >1){
		                $html.='</tr><tr>';
		            }
		            $ff++;
		        }       

		    }
		}
		$html.='</tr>';


		$ff=1;

		$html.='<tr>';
		foreach($resu->result() as $demand){
		    
		    foreach ($object_fields as $f_name) {

		        if( $f_name!='client_id'  AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
		            AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' AND $f_name!='status' 
		            AND $f_name!='ref_client_verify_code' AND $f_name!='demand_id' AND $f_name!='client_contact_id' 
		            AND $f_name!='point_count' AND $f_name!='shop_point_id' AND $f_name!='owner' AND $f_name!='object_id'      )
		        if( !empty($demand->$f_name)     AND 
		             $demand->$f_name!='0.00'  ){

		                $html.='<td>'.$demand->$f_name;
		                

		                $html.='</td>';

		                
		            if($ff%5==0 AND $ff >1){
		                $html.='</tr><tr>';
		            }
		            $ff++;
		            
		        }       

		    }
		    
		}

		$html.='</tr></table>';

		return $html;


    }

//顯示你的比對資料
     function demand($demand_res , $demand_fields ){

     	$html ='<h5 style="font-size:17px;">需求</h5>';
     	$ff=1;
		$html.='<table style="margin:10px 0 10px 0;color:red;"><tr>';
		foreach($demand_res->result() as $demand){
			foreach ($demand_fields as $f_name) {

				if($f_name!='demand_id' AND $f_name!='client_id' AND $f_name!='client_contact_id' AND $f_name!='point_count'
					AND $f_name!='shop_point_id' AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
					AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' 
					AND $f_name!='ref_client_verify_code' AND $f_name!='owner' AND $f_name!='status' 		)
			 	if( !empty($demand->$f_name) AND $demand->$f_name !='0' ){

			 		$html.='<th>'.$f_name.'</th>';
			 		if($ff%5==0 AND $ff >1){
			 			
			 			$html.='</tr><tr>';
			 		}
			 		$ff++;
			 	}	 	

			}
		}
		$html.='</tr>';
		$ff=1;
		$html.='<tr>';
		foreach($demand_res->result() as $demand){
			foreach ($demand_fields as $f_name) {

				if($f_name!='demand_id' AND $f_name!='client_id' AND $f_name!='client_contact_id' AND $f_name!='point_count'
					AND $f_name!='shop_point_id' AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
					AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' 
					AND $f_name!='ref_client_verify_code' 	AND $f_name!='owner'	 AND $f_name!='status' )
			 	if( !empty($demand->$f_name) AND $demand->$f_name !='0' ){
			 		$html.='<td>'.$demand->$f_name.'</td>';
			 		if($ff%5==0 AND $ff >1){

			 			$html.='</tr><tr>';
			 		}
			 		$ff++;
			 	}	 	

			}
		}

		$html.='</tr></table>';

		return $html;

     }


     function max($demand_res , $demand_fields ){

     	$html ='<h5 style="font-size:17px;">MAX</h5>';
     	$ff=1;
		$html.='<table style="margin:10px 0 10px 0;color:red;"><tr>';
		foreach($demand_res->result() as $demand){
			foreach ($demand_fields as $f_name) {

				if( $f_name!='demand_id' AND $f_name!='client_id'  
					AND $f_name!='client_id' AND $f_name!='client_contact_id' AND $f_name!='point_count'
					AND $f_name!='shop_point_id' AND $f_name!='head' AND $f_name!='broker'  
					AND $f_name!='ctime' AND $f_name!='dtime' AND $f_name!='mtime' 
					AND $f_name!='front_man' AND $f_name!='ref_client_verify_code' AND $f_name!='owner'
					AND $f_name!='status' AND $f_name!='object_id' 		)
			 	if( !empty($demand->$f_name) AND $demand->$f_name !='0' ){

			 		$html.='<th>'.$f_name.'</th>';
			 		if($ff%5==0 AND $ff >1){
			 			
			 			$html.='</tr><tr>';
			 		}
			 		$ff++;
			 	}	 	

			}
		}
		$html.='</tr>';
		$ff=1;
		$html.='<tr>';
		foreach($demand_res->result() as $demand){
			foreach ($demand_fields as $f_name) {

				if($f_name!='demand_id' AND $f_name!='client_id' AND $f_name!='client_contact_id' AND $f_name!='point_count'
					AND $f_name!='shop_point_id' AND $f_name!='head' AND $f_name!='broker'  AND $f_name!='ctime' 
					AND $f_name!='dtime' AND $f_name!='mtime' AND $f_name!='front_man' 
					AND $f_name!='ref_client_verify_code' 	AND $f_name!='owner'	)
			 	if( !empty($demand->$f_name) AND $demand->$f_name !='0' ){
			 		$html.='<td>'.$demand->$f_name.'</td>';
			 		if($ff%5==0 AND $ff >1){

			 			$html.='</tr><tr>';
			 		}
			 		$ff++;
			 	}	 	

			}
		}

		$html.='</tr></table>';

		return $html;

     }



}